#include "loghandle.h"

#include <QPlainTextEdit>
#include <QDebug>

LogHandle::LogHandle(QPlainTextEdit *p_text_edit) {
    p_tedit = p_text_edit;
}

LogHandle::~LogHandle() {
    if(p_tedit != nullptr) {
        p_tedit->appendPlainText(t_data);
    }
    qDebug().noquote() << t_data;
}

void LogHandle::print(QString data) {
    t_data = data;
}

LogHandle &LogHandle::operator<<(QString data) {
    t_data = t_data == "" ? data : QString("%1 %2").arg(t_data, data);
    return *this;
}
